package com.example.fashionshoes.pojo.po;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    //0表示失败，1表示成功
    private Integer code;
    //错误信息
    private String msg;
    private T data;
    public static <T> Result<T> success(){
        Result<T> result = new Result<>();
        result.code = 1;
        return result;
    }
    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>();
        result.code = 1;
        result.data = data;
        return result;
    }
    public static <T> Result<T> error(String msg){
        Result<T> result = new Result<>();
        result.code = 0;
        result.msg = msg;
        return  result;
    }
    public static <T> Result<T> error(String msg,Integer code,T data){
        Result<T> result = new Result<>();
        result.code = code;
        result.msg = msg;
        result.data = data;
        return result;
    }
}
